#include <cstdio>


/**

 * Minecraft
 * 
 */
int n, ans = 6000;
int main() {
    scanf("%d", &n);
    for (int i = 1; i * i * i <= n; ++i) {
        for (int j = i; i * j * j <= n; ++j) {
            if (n % (i * j) == 0) {
                int k = n / i / j;
                if (i * j + i * k + j * k < ans) {
                    ans = i * j + i * k + j * k;
                }
            }
        }
    }
    printf("%d\n", ans * 2);
    return 0;
}